﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;

namespace JiveMessenger.Models
{
    [DataContract]
    public class JiveCustomEmoticonModel : INotifyPropertyChanged, IEmoticon,IEquatable<IEmoticon>
    {
        public EmoticonType Type
        {
            get
            {
                return EmoticonType.CustomEmoticon;
            }
        }

        private string _emoticonShortcut;
        [DataMember]
        public string EmoticonShortcut
        {
            get { return _emoticonShortcut; }
            set
            {
                if (_emoticonShortcut != value)
                {
                    _emoticonShortcut = value;
                    RaisePropertyChanged("EmoticonShortcut");
                }
            }
        }

        private string _emoticonPath;
        [DataMember]
        public string EmoticonPath
        {
            get { return _emoticonPath; }
            set
            {
                if (_emoticonPath != value)
                {
                    _emoticonPath = value;
                    RaisePropertyChanged("EmoticonPath");
                }
            }
        }
        private int _rowSpan;
        public int RowSpan
        {
            get { return _rowSpan; }
            set
            {
                if (_rowSpan != value)
                {
                    _rowSpan = value;
                    RaisePropertyChanged("RowSpan");
                }
            }
        }

        private int _colSpan;
        public int ColSpan
        {
            get { return _colSpan; }
            set
            {
                if (_colSpan != value)
                {
                    _colSpan = value;
                    RaisePropertyChanged("ColSpan");
                }
            }
        }


        public JiveCustomEmoticonModel()
        {

        }

        protected void RaisePropertyChanged(string propertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
        }
        public event PropertyChangedEventHandler PropertyChanged;

        public override int GetHashCode()
        {
            return (this.EmoticonPath + this.EmoticonShortcut).GetHashCode();
        }

        public override bool Equals(object obj)
        {
            return Equals(obj as IEmoticon);
        }
        public bool Equals(IEmoticon other)
        {
            if (other == null || !(other is JiveCustomEmoticonModel))
                return false;
            return this.EmoticonPath == other.EmoticonPath && this.EmoticonShortcut== ((JiveCustomEmoticonModel)other).EmoticonShortcut;
        }
    }
}
